#ifndef SIMINTERFACE_H
#define SIMINTERFACE_H

#include "type.h"

enum avm_objtype {
	AVM_OBJECT = 201,
	AVM_PARAM,
	AVM_PARAM_NUM,
	AVM_PARAM_BOOL,
	AVM_PARAM_ENUM,
	AVM_PARAM_STRING,
	AVM_PARAM_DATA,
	AVM_LIST
};

class avm_object;
class avm_param;
class avm_param_num;
class avm_param_shadow_num;
class avm_param_bool;
class avm_param_shadow_bool;
class avm_param_enum;
class avm_param_string;
class avm_param_filename;
class avm_param_data;
class avm_list;

class avm_object {
	bit32u id;
	avm_objtype type;
public:
	avm_object(bit32u _id) : id(_id), type(AVM_OBJECT) { }
	virtual ~avm_object() {}
	bit32u get_id() const { return id; }
	void set_type(avm_object _type) { type = _type; }
	bit8u get_type() { return type; }
};

class avm_param : public avm_object {
	static const char *default_text_format;

protected:
	avm_list *parent;
	char *name;
	char *description;
	char *label;
	const char *text_format;
	const char *long_text_format;
	char *ask_format;
	char *group_name;
	int runtime_param;
	int enable;
	bit32u options;
	avm_list *dependent_list;

public:
	avm_param(bit32u _id, const char *_name, const char *_description);
	avm_param(bit32u _id, const char *_name, 
			const char *_label, const char *_description);
	virtual ~avm_param();
	avm_list *get_parent() { return parent; }
	int get_param_path(char *path_out, int max_len);
	void set_format(const char *_format) { format = _format; }
	const char *get_format() const { return format; }
	void set_long_format(const char *_format) { long_text_format = _format; }
	const char *get_long_format() const { return long_text_format; }
	void set_ask_format(const char *_format);
	const char *get_ask_format() const { return ask_format; }
	void set_label(const char *_label);
	const char *get_label() const { return label; }
	void set_description(const char *_description);
	const char *get_description() const { return description; }
	void set_runtime(int val) { runtime_param = val; }
	int get_runtime() const { return runtime_param; }
	void set_group(const char *_group_name);
	const char *get_group() const { return group_name; }
	const char *get_name const { return name; }
	virtual void set_enabled(int _enabled) { enable = _enabled; }
	int get_enabled() const { return enable; }
	virtual void reset() {}
	avm_list *get_dependent() const { return dependent_list; }
	void set_options(bit32u _options) { options = _options; }
	bit32u get_options() const { return options; }
	static const char * set_default_format(const char *_format);
	static const char *get_default_format() const { return default_text_format; }
};

enum avm_stringopt {
	RAW_BYTES         = 1,
	IS_FILENAME       = 2,
	SAVE_FILE_DLG     = 4,
	SELECT_FOLDER_DLG = 8
};

class avm_param_string;

typedef int (* param_enable_handler)(avm_param *, int);
typedef const char *(* param_string_event_handler)(avm_param_string *,
		int set, const char *old, const char *newchar, int maxlen);

class avm_param_string : public avm_param {
private:	
	int maxsize;
	char *val;
	char *initial;
	param_string_event_handler handler;
	param_enable_handler enable_handler;
	char separator;
	avm_stringopt avm_stringopt_bits;

public:
	avm_param_string(avm_param *_parent, const char * _name, const char *_label
			const char *_description, const char *initial, int _maxsize = -1);
	virtual ~avm_param_string();
	virtual void reset();
	void set_handler(param_string_event_handler _handler) { handler = _handler; };
	void set_enable_handler(param_string_enable_handler _handler) { enable_handler = _handler; }
	virtual void set_enabled(int _enabled);
	void set_dependent_list(avm_list *l);

	void update_dependents();
};

enum avm_listopt {
	SHOW_PARENTS = 1,
	SERIES_ASK,
	USE_TAB_WINDOW,
	USE_BOX_TITLE
};

class avm_list : public avm_param {
	avm_list **list;
	int size;
	int max_size;

};

#endif

